<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * @property float $pay_amount 支付金额
 * @property int $deletetime
 * @property int $id
 * @property int $option_id 会员类型
 * @property int $pay_status 状态:1=未支付,2=已支付
 * @property int $paytime 支付时间
 * @property int $user_id 用户
 * @property string $createtime
 * @property string $order_sn 订单编号
 * @property-read \app\model\User $user
 * @property-read mixed $paytime_text
 * @method static \think\db\Query onlyTrashed()
 * @method static \think\db\Query withTrashed()
 * @mixin \think\Model
 */
class VipOrders extends Model
{
	use SoftDelete;
	//
	protected $createTime = 'createtime';
	protected $deleteTime = 'deletetime';
	
	protected $append = [
		'paytime_text',
	];
	
	function getPaytimeTextAttr($value,$data)
	{
		$value = $value ?? ($data['paytime'] ?? "");
		return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
	}

	
	function user()
	{
		return $this->belongsTo(User::class, 'user_id', 'id');
	}
}
